#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int n = 0;
    int m = 0;
    int arr[2000];
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    for (int i = n; i < (n + m); i++)
    {
        scanf("%d", &arr[i]);
    }
    for (int i = 0; i < n + m - 1; i++)
    {
        for (int j = 0; j < n + m - 1 - i; j++)
        {
            if (arr[j] > arr[j + 1])
            {
                int tmp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = tmp;
            }
        }
    }
    for (int i = 0; i < (n + m); i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}